package anc.tankshooter.network;


public abstract class GamePlayingListener implements IPacketReceiver {

	@Override
	public void onConnected() {
		
	}

	@Override
	public void onDisconnected() {
		
	}
	@Override
	final public void onReceive(int command,String data) {
		String[] info;
		switch(command){
		case CommandList.SERVER_RUN:
			info = data.split(":");
			if(info!=null && info.length==2){
				int accountId = Integer.valueOf(info[0]);
				int dir = Integer.valueOf(info[1]);
				onTankMoving(accountId,dir);
			}
			break;
		case CommandList.SERVER_FIRE:
			info = data.split(":");
			if(info!=null && info.length==3){
				int accountId = Integer.valueOf(info[0]);
				float x = Float.valueOf(info[1]);
				float y = Float.valueOf(info[2]);
				onFire(accountId, x, y);
			}
			break;
		case CommandList.SERVER_PAUSE:
			onPause();
			break;
		case CommandList.SERVER_RESUME:
			onResume();
			break;
		case CommandList.SERVER_PLAYER_GIVEUP:
			int accountId = Integer.valueOf(data);
			onPlayerGiveUp(accountId);
			break;
		case CommandList.SERVER_DISCONNECTED:
			onServerDisconnected();
			break;
		}
	}
	
	public abstract void onTankMoving(int accountId,int movingDir);
	public abstract void onFire(int accountid,float x,float y);
	public abstract void onPause();
	public abstract void onResume();
	public abstract void onPlayerGiveUp(int accountId);
	public abstract void onServerDisconnected();
	
}
